package com.ruoyi.dingtalk.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * 钉钉用户信息
 *
 * @author xueyu
 */
@ApiModel(value = "钉钉用户信息")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@AllArgsConstructor
@TableName(value = "dd_user")
@Entity
@Table(name = "dd_user")
public class DdUser extends BaseEntity implements Serializable {

    private static final long serialVersionUID = -3818306456333640144L;

    /**
     * 钉钉用户id
     */
    @ApiModelProperty(value = "钉钉用户id")
    @Id
    @Column(name = "user_id")
    @TableId(value = "user_id", type = IdType.NONE)
    private String userId;

    /**
     * 钉钉企业id
     */
    @ApiModelProperty(value = "钉钉企业id")
    @Column(name = "dd_corp_id")
    @TableField(value = "dd_corp_id")
    private String ddCorpId;

    /**
     * 系统用户id
     */
    @ApiModelProperty(value = "系统用户id")
    @Column(name = "sys_userid")
    @TableField(value = "sys_userid")
    private Long sysUserId;

    /**
     * 姓名
     */
    @ApiModelProperty(value = "姓名")
    @Column(name = "ding_talk_user_name")
    @TableField(value = "ding_talk_user_name")
    private String dingTalkUserName;

    /**
     * 钉钉上级直属主管id
     */
    @ApiModelProperty(value = "钉钉上级直属主管id")
    @Column(name = "manager_user_id")
    @TableField(value = "manager_user_id")
    private String managerUserId;
    /**
     * 手机号
     */
    @ApiModelProperty(value = "手机号")
    @Column(name = "mobile")
    @TableField(value = "mobile")
    private String mobile;
    /**
     * 工号
     */
    @ApiModelProperty(value = "工号")
    @Column(name = "job_number")
    @TableField(value = "job_number")
    private String jobNumber;

    /**
     * 职位
     */
    @ApiModelProperty(value = "职位")
    @Column(name = "position")
    @TableField(value = "position")
    private String position;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱")
    @Column(name = "email")
    @TableField(value = "email")
    private String email;

    /**
     * 企业邮箱
     */
    @ApiModelProperty(value = "企业邮箱")
    @Column(name = "org_email")
    @TableField(value = "org_email")
    private String orgEmail;

    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;
        Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
        Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
        if (thisEffectiveClass != oEffectiveClass) return false;
        DdUser ddUser = (DdUser) o;
        return getUserId() != null && Objects.equals(getUserId(), ddUser.getUserId());
    }

    @Override
    public final int hashCode() {
        return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
    }
}
